<template>
  <el-dialog :title="title" :visible.sync="open" width="750px" append-to-body>
    <el-container>
			<el-aside class="el-aside">
				<el-menu :default-active="selectedType" @select="handleTypeChange">
					<el-menu-item v-for="item in typeList" :key="item.value" :index="item.value" >
						{{item.label}}
					</el-menu-item>
				</el-menu>
			</el-aside>
			
			<el-main>
				<el-table height="500" v-loading="loading" :data="collegeList">
					<!-- <el-table-column label="名称" align="center" :formatter="formatterType" /> -->
					<el-table-column label="学院" align="left" prop="orgName" />
					<el-table-column label="汇总状态" align="center" prop="status" :formatter="formatterStatus" />
				</el-table>
			</el-main>
		</el-container>
		
		<div slot="footer" class="dialog-footer">
			<el-button @click="cancel">关 闭</el-button>
		</div>
  </el-dialog>
</template>

<script>
import { listBaseCollege } from "@/api/statistics/baseCollege";

export default {
  name: "DirectStatistics",
	props: {
		typeList: Array,
		baseId: Number,
		collegeList: Array
	},
  data() {
    return {
			open: false,
      // 遮罩层
      loading: false,
      // 总条数
      total: 0,
			// 学院List
			baseCollegeList: [],
			// 选中类型
			selectedType: "1",
      // 弹出层标题
      title: "",
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 100
      }
    };
  },
  created() {
  },
  methods: {
		formatterStatus(row, column) {
			const college = this.baseCollegeList.find(item => item.collegeOrgId == row.orgId)
			if (college) {
				if (college.status == '1') {
					return '已转汇总表'
				}
			}
			return ''
			// if (row.status == '1') {
			// 	return '已转汇总表'
			// }
			// return ''
		},
		formatterType(row, column) {
			const type = this.typeList.find(item => item.value == row.type)
			if (type) {
				return type.label
			}
			return ''
		},
		formatterCollegeOrgId(row, column) {
			const college = this.collegeList.find(item => item.orgId == row.collegeOrgId)
			if (college) {
				return college.orgName
			}
			return ''
		},
		handleTypeChange(value) {
			this.selectedType = value
			this.getList()
		},
    /** 查询高基列表 */
    getList() {
			this.queryParams.baseId = this.baseId
			this.queryParams.type = this.selectedType
      this.loading = true;
      listBaseCollege(this.queryParams).then(response => {
        this.baseCollegeList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
    },
    /** 新增按钮操作 */
    handleShow() {
      this.title = "汇总统计"
      this.open = true
			this.selectedType = "1"
			this.getList()
    }
  }
};
</script>

<style lang="scss" scoped>
.el-header {
	border-bottom: 1px solid #dfe4ed;
}
.el-aside {
	width: 300px;
	background-color: white;
	min-height: 500px;
}
</style>
